﻿using Compass.Wasm.Shared.Categories;
using Compass.Wasm.Shared.Logistics;
using Zack.DomainCommons.Models;

namespace Compass.LogisticService.Domain.Entities;

public record ImportExportInfo : AggregateRootEntity, IAggregateRoot, IHasCreationTime, ISoftDelete
{
    //进出口申报信息表上体现的信息
    public string MtlNumber { get; private set; }//尽量写料号（可以写多个），其余的写
    public ImportExportType_e Type { get; private set; }
    public Sbu_e Sbu { get; private set; }

    //查询HSCode网站：https://www.hscode.net/IntegrateQueries/QueryYS/
    public string Name { get; private set; }//商品名称，报关行->采购->系统
    public string HsCode { get; private set; }//商品编码
    public string HsDescription { get; private set; }//商品描述
    public string PlaceOfOrigin { get; private set; }//产地
    public string DeclarationElements { get; private set; }//申报要素

    public double NetWeight { get; private set; }//净重
    public string? PoNumbers { get; private set; }//以前采购过的订单号码
    public string? NavDescription { get; private set; }//公司Nav上描述
    public string? AttachmentsUrl { get; private set; }//上多个PDF附件
    public string? ImagesUrl { get; private set; }//上传多张图片

    #region ctor
    private ImportExportInfo() { }
    public ImportExportInfo(Guid id, string mtlNumber, ImportExportType_e type, Sbu_e sbu, string name,
        string hsCode, string hsDescription, string placeOfOrigin, string declarationElements,
        double netWeight, string? poNumbers, string? navDescription, string? attachmentsUrl, string? imagesUrl)
    {
        Id=id;
        MtlNumber = mtlNumber;
        Type = type;
        Sbu = sbu;
        Name = name;
        HsCode=hsCode;
        HsDescription = hsDescription;
        PlaceOfOrigin = placeOfOrigin;
        DeclarationElements = declarationElements;
        NetWeight = netWeight;
        PoNumbers = poNumbers;
        NavDescription = navDescription;
        AttachmentsUrl = attachmentsUrl;
        ImagesUrl = imagesUrl;
    }
    #endregion

    #region update
    public void Update(ImportExportInfoDto dto)
    {
        ChangeMtlNumber(dto.MtlNumber)
            .ChangeType(dto.Type)
            .ChangeSbu(dto.Sbu)
            .ChangeName(dto.Name)
            .ChangeHsCode(dto.HsCode)
            .ChangeHsDescription(dto.HsDescription)
            .ChangePlaceOfOrigin(dto.PlaceOfOrigin)
            .ChangeDeclarationElements(dto.DeclarationElements)
            .ChangeNetWeight(dto.NetWeight)
            .ChangePoNumbers(dto.PoNumbers)
            .ChangeNavDescription(dto.NavDescription)
            .ChangeAttachmentsUrl(dto.AttachmentsUrl)
            .ChangeImagesUrl(dto.ImagesUrl);

        NotifyModified();
    }
    public ImportExportInfo ChangeMtlNumber(string mtlNumber)
    {
        MtlNumber = mtlNumber;
        return this;
    }
    public ImportExportInfo ChangeType(ImportExportType_e type)
    {
        Type = type;
        return this;
    }
    public ImportExportInfo ChangeSbu(Sbu_e sbu)
    {
        Sbu = sbu;
        return this;
    }
    public ImportExportInfo ChangeName(string name)     
    {
        Name = name;
        return this;
    }
    public ImportExportInfo ChangeHsCode(string hsCode)
    {
        HsCode = hsCode;
        return this;
    }
    public ImportExportInfo ChangeHsDescription(string hsDescription)
    {
        HsDescription = hsDescription;
        return this;
    }
    public ImportExportInfo ChangePlaceOfOrigin(string placeOfOrigin)
    {
        PlaceOfOrigin = placeOfOrigin;
        return this;
    }
    public ImportExportInfo ChangeDeclarationElements(string declarationElements)
    {
        DeclarationElements = declarationElements;
        return this;
    }
    public ImportExportInfo ChangeNetWeight(double netWeight)
    {
        NetWeight = netWeight;
        return this;
    }
    public ImportExportInfo ChangePoNumbers(string? poNumbers)
    {
        PoNumbers = poNumbers;
        return this;
    }
    public ImportExportInfo ChangeNavDescription(string? navDescription)
    {
        NavDescription = navDescription;
        return this;
    }
    public ImportExportInfo ChangeAttachmentsUrl(string? attachmentsUrl)
    {
        AttachmentsUrl = attachmentsUrl;
        return this;
    }
    public ImportExportInfo ChangeImagesUrl(string? imagesUrl)
    {
        ImagesUrl = imagesUrl;
        return this;
    }
    #endregion

}